package com.zzyl.controller.customer;

import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import com.zzyl.base.PageBean;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectPageQueryDto;
import com.zzyl.dto.OrderQueryDto;
import com.zzyl.service.NursingProjectService;
import com.zzyl.service.OrderService;
import com.zzyl.utils.ThreadLocalUtil;
import com.zzyl.vo.NursingProjectVo;
import com.zzyl.vo.OrderVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "客户订单管理")
@RestController
@RequestMapping("/customer/orders")
@Slf4j
public class CustomOrderController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private NursingProjectService nursingProjectService;


    /**
     * 根据编号查询护理项目信息
     *
     * @param id 护理项目ID
     * @return {@code ResponseResult<NursingProjectVo> }
     * @author YiSheep
     */
    @ApiOperation("根据编号查询护理项目信息")
    @GetMapping("/project/{id}")
    public ResponseResult<NursingProjectVo> getNursingProjectById(@PathVariable Long id){
        log.info("根据编号查询护理项目信息:{}", id);
        NursingProjectVo nursingProjectVo = nursingProjectService.getById(id);
        return ResponseResult.success(nursingProjectVo);
    }

    /**
     * 分页查询护理项目列表
     *
     * @param dto 护理项目分页条件查询Dto
     * @return {@code ResponseResult<PageBean<NursingProjectVo>> }
     * @author YiSheep
     */
    @ApiOperation("分页查询护理项目列表")
    @GetMapping("/project/page")
    public ResponseResult<PageBean<NursingProjectVo>> searchNursingProjects(NursingProjectPageQueryDto dto){
        log.info("查询护理项目列表");
        PageBean<NursingProjectVo> pageBean = nursingProjectService.pageQuery(dto);
        return ResponseResult.success(pageBean);
    }



    ///////////////////////////////////////////////////////////////////////////////


    @ApiOperation("分页查询订单")
    @GetMapping("/order/page")
    public ResponseResult<PageBean<OrderVo>> searchOrders(OrderQueryDto dto) {
        dto.setUserId(ThreadLocalUtil.get());
        PageBean<OrderVo> pageBean = orderService.searchOrders(dto);
        return ResponseResult.success(pageBean);
    }
}

